#pragma once

#include <iostream>
#include <vector>

using namespace std;

class Routine;
class Memory;
class Data;
class DataHolder;
class Instruction;

class Program {
public:
	
	Program(const string& name);
	~Program();
	
	void addRoutine(Routine* routine);
	void run();
	
	Memory* getMemory() { return m_memory; }
    
private:
	
	string m_name;
	
	typedef vector<Routine*> Routines;
	Routines m_routines;

	void executeRoutine(int index);
	
	Memory* m_memory;
	
	void executeInstruction_CREATE_VARIABLE(Instruction* currentInstruction);
	void executeInstruction_ASSIGN_VARIABLE(Instruction* currentInstruction);
	Data* calculateValueOfDataHolder(DataHolder* dataHolder);
};